package com.lvan.producer.send;

import com.lvan.producer.channel.MyProcessor;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.messaging.support.MessageBuilder;
import org.springframework.stereotype.Component;

/**
 * @author luom
 * @date 2021/9/3
 */
@Component
@EnableBinding(MyProcessor.class)
public class SourceMessageProducer {

    private final Logger logger = LoggerFactory.getLogger(SourceMessageProducer.class);

    @Autowired
    private MyProcessor myProcessor;

    /**
     * 发送原始消息 10086|10068@email.com
     * @param message 消息
     */
    public void send(String message) {
        logger.info("原始消息发送成功，原始消息为:{}", message);
        myProcessor.sourceOutput().send(MessageBuilder.withPayload(message).build());
    }
}
